<?php defined('SYSPATH') or die('No direct script access.');

class Model_Category extends ORM
{ 
    protected $_table_name = 'categories'; 
    protected $_reload_on_wakeup = false; 

    public function add_category($name)
    {
        $this->name = $name;
        $this->save();
        
        return $this;
    }
    
    public function get_categories()
    {
        return $this->_get_categories_query()->order_by('id', 'ASC')->find_all();  
    }
    
    protected function _get_categories_query()
    {
        return ORM::factory('category');  
    }
    
    public function get_breadcrumbs()
    {
        /*$breadcrumbs = array();
        $category_id = $this->parent_id;
        $old_category_id = $category_id;
        
        while ($category_id) {
            $category = ORM::factory('category', $category_id);
            $breadcrumbs[] = $category;   
            
            $category_id = $category->parent_id;
        }
        
        $breadcrumbs = array_reverse($breadcrumbs);
        return $breadcrumbs;*/    
    }
}